﻿using System;
using System.Collections.Generic;
using System.Text;
using XNAchievement;
using XNAchievement.Achievements;

namespace AchievementTestGame
{
    class UnlockGameScreen : MenuScreen
    {
        public UnlockGameScreen()
            : base("The \"Game\"")
        {
            //This is the "game" it consists of some buttons and you can earn achievements while pressing them ;)
            MenuEntry SimpleUnlockMenuEntry = new MenuEntry("Select me!");
            MenuEntry BackMenuEntry = new MenuEntry("Back");

            SimpleUnlockMenuEntry.Selected += new EventHandler<PlayerIndexEventArgs>(SimpleUnlockMenuEntry_Selected);
            BackMenuEntry.Selected += OnCancel;

            MenuEntries.Add(SimpleUnlockMenuEntry);
            MenuEntries.Add(BackMenuEntry);
        }

        void SimpleUnlockMenuEntry_Selected(object sender, PlayerIndexEventArgs e)
        {
            //The first button was pressed, we handle the achievement progress here
            ScreenManager.AchievementManager.GetByName("simple_select").Unlock(); //The simple one, just unlock it. (No problem if is was already unlocked)
            ((CounterAchievement)ScreenManager.AchievementManager["select_count"]).IncreaseCounter(); //Increase the counter. Note the index operator ([]). It works like GetByName().

            ((XInTimeAchievement)ScreenManager.AchievementManager["select_fast"]).ActionDone();
        }
    }
}
